package com.freight.tws.controller;

import com.freight.common.core.web.controller.BaseController;
import com.freight.common.core.web.domain.AjaxResult;
import com.freight.tws.service.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 统计
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/count")
public class CountController extends BaseController {

    private final IOrderService orderService;
    private final ITwsCompanyService companyService;
    private final IDriverService driverService;
    private final IVehicleService vehicleService;

    /**
     * 首页 - 基础信息数量统计
     */
    @GetMapping("/counts")
    public AjaxResult counts() {
        Map<String, Integer> map = new HashMap<>();
        map.put("orderCount", orderService.count());
        map.put("companyCount", companyService.count());
        map.put("driverCount", driverService.count());
        map.put("vehicleCount", vehicleService.count());
        return AjaxResult.success(map);
    }

    /**
     * 首页 - 订单折线图
     */
    @GetMapping("/orderLineChartCount")
    public AjaxResult orderLineChartCount(@RequestParam("date") String date) {
        return AjaxResult.success(orderService.orderLineChartCount(date));
    }

}
